package com.lcm.learn.lcmcode.EscapeAnalysis;

import lombok.Data;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @description:
 * @author: lcm
 * @create: 2019-12-02 15:59
 **/

public class AllotOnStack {



    @Data
    public static class User{
        public int id=0;
        public String name="";
    }

    public static void main(String[] args) {
        ExecutorService pool = Executors.newFixedThreadPool(5);
        long start = System.currentTimeMillis();
        for (int i = 0; i < 100000000; i++) {
            pool.submit(new Runnable() {
                @Override
                public void run() {
                    alloc();
                }
            });
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);
    }

    private static void alloc() {
        User user = new User();
        user.setId(1);
        user.setName("zengxinyao");
        //return user;
    }

}
